#include "FPSCounter.h"

FpsCounter::FpsCounter(): Current_fps(0), Frames_This_Second(0),Time_Since_Last_Second(0)
{

}

void FpsCounter::Update(float msec)
{
	// increase the counter by one
	Frames_This_Second++;

	//increase time since msec
	Time_Since_Last_Second += msec;

	// one second elapsed? (= 1000 milliseconds)
	if (Time_Since_Last_Second > 1000.0f)
	{
		//set FPS tp frames this second
		Current_fps = Frames_This_Second;
            
		//reset frame and time counter
		Frames_This_Second = 0;
		Time_Since_Last_Second = 0.0f;
	}
}
